<?php
/**
 * 
 * @author hushuai
 *
 */
class RestaurantAction extends CommonAction{
	
	public function index(){
		
		$model = D("Restaurant");
		session('dliveryfee','');//设置配送费为空
		
		if($_GET['addressid']){
			$addressid = $this->_param('addressid','intval',0);
			$model->setUserSession($addressid);
		}
		
		$query = addressJsonDecode();
		foreach($query as $k=>$v){
			$query[$k] = urldecode($v);
		}
		$map['cuisine']  = $this->_param("cuisine","intval",0);
		
		//如果没有选择城市或者没有选择具体地址，那么就要返回去重新选择
		if(empty($query['city'])||empty($query['adds'])){
			$this->assign("noneCity","1");
		}
		
		$cuisine = $model->getCuisine($query);               //所有英文菜系
		$list    = $model->getOutletArray($query);           //poi云检索，获取用户周边一定范围的圆形区域内的餐厅列表数据

		Log::write('RestaurantAction:'.var_export($list,true),Log::DEBUG);
		$view    = $model->getRestaurantArray($list,$map);   //遍历数组，进行距离和时间分段处理(包含筛选操作)
		$view    = $model->setRestaurantArray($view);        //循环餐厅列表将菜系字符串转成数组(其他相应操作)
		$article = $model->getArticleList();                 //获取最新消息
		
		$this->assign("article",$article);
		$this->assign("query",$query);
		$this->assign("cuisine",$cuisine);
		$this->assign("view",$view);
		
		//公司公告
		$CITY  = C('CITYID');
		$lang  = getLang();
		$announcement = get_syscfig_key($CITY[$query['cityid']][0].'_announcement'.$lang);
		$this->assign('announcement',$announcement);
		
		$this->display();
	}
	
}
?>
